package com.s3.khospitalds.controller;

import com.s3.khospitalds.common.R;
import com.s3.khospitalds.entity.Patienthosp;
import com.s3.khospitalds.service.PatienthospService;
import com.s3.khospitalds.service.impl.PatienthospServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: xw
 * @CreateTime: 2025/3/6
 * @Description: 住院患者档案表
 * @Version: 1.0
 */
@RestController
@CrossOrigin(origins = "*")
public class PatienthospController {
    @Autowired
    private PatienthospServiceImpl patienthospService;
    @PostMapping("/insertPatienthosp")
    public R insertPatienthosp(@RequestBody Patienthosp patienthosp) {
        return new R().addData("insertPatienthosp",patienthospService.insertPatienthosp(patienthosp));
    }
    @GetMapping("/getPatienthospByName/{name}")
    public R getPatienthospByName(@PathVariable("name") String name) {
        return new R().addData("list",patienthospService.selectName(name));
    }
    @PostMapping("/updatePatienthosp")
    public R updatePatienthosp(@RequestBody Patienthosp patienthosp) {
        return new R().addData("bol",patienthospService.updateName(patienthosp));
    }
    @PostMapping("/deletePatienthosp")
    public R deletePatienthosp(@RequestBody int id) {
        return new R().addData("bol",patienthospService.deleteById(id));
    }
}
